
package data;

import com.alibaba.fastjson.JSON;

import io.netty.channel.ChannelHandlerContext;

//消息派发
public class messageDispath {
	private messageDispath() {
	}

	private static final messageDispath instance = new messageDispath();

	public static messageDispath getInstance() {
		return instance;
	}


	
	
	
	public void MessageDispath(int msgid,String str,ChannelHandlerContext ctx ) {
		

		if (msgid == ProtocolEnum.C2S_Login) {
			LoginMessage msgobj= JSON.parseObject(str, LoginMessage.class);
			MessageAction.getInstance().c2sLogin(ctx, msgobj);
			return;
		}

		if (msgid == ProtocolEnum.C2S_Shoot) {
			ShootMessage msgobj= JSON.parseObject(str, ShootMessage.class);
			MessageAction.getInstance().c2sShoot(ctx, msgobj);
			return;
		}
		if (msgid == ProtocolEnum.C2S_Move) {
			MoveMessage msgobj= JSON.parseObject(str, MoveMessage.class);
			MessageAction.getInstance().c2sMove(ctx, msgobj);
			return;
		}
		if (msgid == ProtocolEnum.C2S_ShootEnd) {
			ShootEndMessage msgobj= JSON.parseObject(str, ShootEndMessage.class);
			MessageAction.getInstance().c2sShootEnd(ctx, msgobj);
			return;
		}
		
		if (msgid == ProtocolEnum.C2S_PutWriteBall) {
			PutWritBallMessage msgobj= JSON.parseObject(str, PutWritBallMessage.class);
			MessageAction.getInstance().c2sPutWriteBall(ctx, msgobj);
			return;
		}
		
		if (msgid == ProtocolEnum.C2S_GetShootColor) {
			SetColorMessage msgobj= JSON.parseObject(str, SetColorMessage.class);
			MessageAction.getInstance().c2sSetColor(ctx, msgobj);
			return;
		}
	}

}
